package com.alks.function.controller.stockdept.pcfactorystockquery;


import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.DrawActMtlRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.DrawActProRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.DrawDetailRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.DrawReMtlRequest;
import com.alks.function.data.vo.MtlBaseVo;
import com.alks.function.service.stockdept.pcfactorystockquery.IReciveMtlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-领料确认作业")
@Slf4j
@RoleCheck(prgIds = {"160108"})
public class ReciveMtlController {
    @Autowired
    IReciveMtlService service;

    @PutMapping("/getDrawDetailQuery")
    @ApiOperation(value = "领料确认作业-领料明细查询-分页可条件查询", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo getDrawDetailQuery(@RequestBody DrawDetailRequest request) {
        return service.getDrawDetailQuery(request);
    }

    @PostMapping("/getDrawActQuery")
    @ApiOperation(value = "领料确认作业-实发明细查询-条件查询", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo getDrawActQuery(@RequestParam Integer id) {
        return service.getDrawActQuery(id);
    }

    @PutMapping("/getDrawReMtlQuery")
    @ApiOperation(value = "领料确认作业-替代物料查询-分页可条件查询", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo getDrawReMtlQuery(@RequestBody DrawReMtlRequest request) {
        return service.getDrawReMtlQuery(request);
    }

    @PutMapping("/DrawActPro")
    @ApiOperation(value = "领料确认作业-实发批处理-修改和新增", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo drawActPro(@RequestBody List<DrawActProRequest> request,
                                   @RequestParam(required = false) @ApiParam("是否确认超量发料标志位 1.确认") Integer flag) {
        return service.DrawActPro(request,flag);
    }

    @PutMapping("/getDrawActMtlQuery")
    @ApiOperation(value = "领料确认作业-材料替代查询-分页可条件查询", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo getDrawActMtlQuery(@RequestBody DrawActMtlRequest request) {
        return service.getDrawActMtlQuery(request);
    }

//    @PostMapping("/drawDetailDelete")
//    @ApiOperation(value = "领料确认作业-整单删除-删除", tags = "仓储部-仓储工厂作业-领料确认作业")
//    public ResponseInfo drawDetailDelete(@RequestParam@ApiParam("补料单号") String slipNo) {
//        return service.drawDetailDelete(slipNo);
//    }

    @PostMapping("/drawDetailCancel")
    @ApiOperation(value = "领料确认作业-取消领料-逻辑删除", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo drawDetailCancel(@RequestParam("mtlNo")@ApiParam("物料编码") String mtlNo,
                                         @RequestParam("slipNo")@ApiParam("补料单号") String slipNo,
                                         @RequestParam("lotNo")@ApiParam("指令") String lotNo) {
        return service.drawDetailCancel(slipNo,mtlNo,lotNo);
    }

    @PostMapping("/draw/mtlReplace")
    @ApiOperation(value = "物料替代处理", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo drawMtlReplace(@RequestParam Integer id,
                                       @RequestBody@ApiParam("替代后物料编号") MtlBaseVo mtl) {
        service.drawMtlReplace(id,mtl);
        return ResponseInfo.ok();
    }

    @PostMapping("/draw/replace/del")
    @ApiOperation(value = "物料替代删除", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo drawReplaceDel(@RequestParam Integer id) {
        service.drawReplaceDel(id);
        return ResponseInfo.ok();
    }

    @GetMapping("/draw/replace/mtlQuery")
    @ApiOperation(value = "物料替代查询", tags = "仓储部-仓储工厂作业-领料确认作业")
    public ResponseInfo drawReplaceMtlQuery(@RequestParam Integer id) {
        MtlBaseVo vo = service.drawReplaceMtlQuery(id);
        return ResponseInfo.ok(vo);
    }

}
